<!DOCTYPE html>
<html>
<head>
    <title>网页内容抓取工具</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .search-box {
            background: white;
            padding: 25px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        .result-container {
            background: white;
            padding: 25px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .error-message {
            color: #d32f2f;
            padding: 15px;
            background-color: #fde7e9;
            border-radius: 4px;
            margin-bottom: 20px;
        }
        .section {
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        .image-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 15px;
        }
        .image-item {
            border: 1px solid #ddd;
            padding: 10px;
            border-radius: 4px;
        }
        .image-item img {
            max-width: 100%;
            height: auto;
            display: block;
        }
        .original-content {
            margin-top: 30px;
            border: 1px solid #ddd;
            padding: 20px;
            background-color: white;
        }
        .original-content img {
            max-width: 100%;
            height: auto;
        }
        .resume-section {
            margin-bottom: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 4px;
        }
        .resume-section h3 {
            margin-top: 0;
            color: #4285f4;
        }
        .project-item {
            margin-bottom: 15px;
            padding: 10px;
            background-color: white;
            border: 1px solid #eee;
            border-radius: 4px;
        }
        .file-saved {
            background-color: #e8f5e9;
            padding: 10px;
            border-radius: 4px;
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <h1>网页内容抓取工具</h1>
    
    <div class="search-box">
        <form method="POST">
            <input type="text" name="url" placeholder="输入URL地址 (例如: https://example.com)" required style="width: 70%; padding: 10px;">
            <button type="submit" style="padding: 10px 20px;">抓取页面</button>
        </form>
    </div>
    
    {% if error %}
        <div class="error-message">{{ error }}</div>
    {% endif %}
    
    {% if page_info %}
    <div class="result-container">
        <!-- 基本信息展示 -->
        <div class="section">
            <h2>基本信息</h2>
            <p><strong>URL:</strong> {{ page_info.url }}</p>
            <p><strong>状态码:</strong> {{ page_info.status_code }}</p>
            <p><strong>标题:</strong> {{ page_info.title or '无标题' }}</p>
            <p><strong>描述:</strong> {{ page_info.meta_description or '无描述' }}</p>
            {% if page_info.saved_file %}
                <div class="file-saved">
                    <strong>数据已保存到:</strong> resume_data/{{ page_info.saved_file }}
                </div>
            {% endif %}
        </div>
        
        <!-- 链接展示 -->
        <div class="section">
            <h2>页面链接 ({{ page_info.links|length }})</h2>
            <table>
                <tr>
                    <th>文本</th>
                    <th>URL</th>
                </tr>
                {% for link in page_info.links %}
                <tr>
                    <td>{{ link.text|truncate(30) }}</td>
                    <td><a href="{{ link.url }}" target="_blank">{{ link.url|truncate(50) }}</a></td>
                </tr>
                {% endfor %}
            </table>
        </div>
        
        <!-- 图片展示 -->
        <div class="section">
            <h2>页面图片 ({{ page_info.images|length }})</h2>
            <div class="image-grid">
                {% for img in page_info.images %}
                <div class="image-item">
                    <img src="{{ img.src }}" alt="{{ img.alt }}" onerror="this.style.display='none'">
                    <div>{{ img.alt }}</div>
                </div>
                {% endfor %}
            </div>
        </div>
        
        <!-- 简历数据展示 -->
        {% if resume_data %}
        <div class="section">
            <h2>生成的简历数据</h2>
            
            <div class="resume-section">
                <h3>技能</h3>
                <ul>
                    {% for skill in resume_data.skills %}
                    <li>{{ skill }}</li>
                    {% endfor %}
                </ul>
            </div>
            
            <div class="resume-section">
                <h3>项目经验</h3>
                {% for project in resume_data.projects %}
                <div class="project-item">
                    <h4>{{ project.name }}</h4>
                    <p>{{ project.description }}</p>
                    <p><strong>技术栈:</strong> {{ project.tech_stack }}</p>
                </div>
                {% endfor %}
            </div>
            
            {% if resume_data.awards %}
            <div class="resume-section">
                <h3>获奖情况</h3>
                <ul>
                    {% for award in resume_data.awards %}
                    <li>{{ award }}</li>
                    {% endfor %}
                </ul>
            </div>
            {% endif %}
            
            <div class="resume-section">
                <h3>自我评价</h3>
                <p>{{ resume_data.self_evaluation }}</p>
            </div>
        </div>
        {% endif %}
        
        <!-- 原始HTML内容 -->
        <div class="original-content">
            <h2>原始页面内容</h2>
            <div>{{ page_info.original_html|safe }}</div>
        </div>
    </div>
    {% endif %}
</body>
</html>